<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<script type="text/javascript" src="js/header.js"></script>
<script type="text/javascript" src="js/layer/layer.js"></script>
<nav class="navbar navbar-inverse  navbar-fixed-top">
    <div>
        <img src="images/header.jpg" style="width: 100%;height: 40px">
    </div>
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <a class="navbar-brand"
                    <c:if test="${type}">
                        href="home.jsp"
                    </c:if>
                    <c:if test="${type == false}">
                        href="userHome.jsp"
                    </c:if>>
                <img alt="RFID" src="images/RFID.png" style="width: 35px;height: 30px">
            </a>
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand"
                    <c:if test="${type}">
                        href="home.jsp"
                    </c:if>
                    <c:if test="${type == false}">
                        href="userHome.jsp"
                    </c:if>>RFID Manage</a>
        </div>
        <!-- 导航条后面 -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <%--管理员导航部分--%>
            <c:if test="${type}">
                <ul class="nav navbar-nav">
                    <li id="user"><a href="javascript:void(0);">用户中心</a></li>
                    <li id="state"><a href="javascript:void(0);">访问记录</a></li>
                    <li id="wxfun"><a href="javascript:void(0);">小程序功能</a></li>
                    <ul class="nav navbar-nav navbar-right" style="margin-left: 2px">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                               aria-haspopup="true"
                               aria-expanded="false">导出数据<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="user/downloadUser">导出用户数据</a></li>
                                <li><a href="record/downloadRecord">导出访问数据</a></li>
                                <li><a href="notice/downloadNotice">导出公告数据</a></li>
                            </ul>
                        </li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right" style="margin-left: 2px">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                               aria-haspopup="true"
                               aria-expanded="false">公告<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li id="add-notice"><a href="${PATH}/notice.jsp">添加公告</a></li>
                                <li id="showNotice"><a href="javascript:void(0);">已发布公告</a></li>
                            </ul>
                        </li>
                    </ul>
                    <c:if test="${userLogin.power==1}">
                        <li id="admin"><a href="javascript:void(0);">管理员中心</a></li>
                    </c:if>
                </ul>
            </c:if>
            <%--用户导航部分--%>
            <c:if test="${type == false}">
                <ul class="nav navbar-nav">
                    <c:if test="${userLogin.flag==1}">
                        <li id="user1" onclick="javascript:updateFlag(0,${userLogin.id});">
                            <a href="javascript:void(0);">挂&nbsp;&nbsp;&nbsp;&nbsp;失</a>
                        </li>
                    </c:if>
                    <c:if test="${userLogin.flag==0}">
                        <li id="user２" onclick="javascript:tips();">
                            <a href="javascript:void(0);">挂失中</a>
                        </li>
                    </c:if>
                    <li id="notice">
                        <a href="${PATH}/userNotice.jsp">通&nbsp;&nbsp;&nbsp;&nbsp;知</a>
                    </li>
                </ul>
            </c:if>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        <img src="images/loginbg1.jpg" style="width: 30px;height: 30px;border-radius:60px"><span style="margin-left:10px;
                        margin-right: 5px" id="username">${userLogin.getName()}</span><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li>
                            <a <c:if test="${type==true}">
                                href="details.jsp"
                            </c:if>
                                    <c:if test="${type==false}">
                                        href="userDetails.jsp"
                                    </c:if> >个人中心
                            </a></li>
                        <li id="exit"><a href="javascript:void(0);" style="color: #f96462">注销</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>


<script>
    $("#exit").click(function () {
        $.get("user/exit", {}, function (json) {
            if (json) {
                location.href = "index.jsp";
            }
        })
    })
    function tips() {
        layer.msg("您的账号已挂失，请到管理员除或使用微信小程序激活！")
    }
</script>